﻿@model AdminGroupModel
@{
	ViewBag.Title = "管理职位";
	Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="pd10">
    <form id="form1">
		<table class="tb-list mt10">
			<tr>
				<td class="aR" style="width:80px;">*名称</td>
				<td class="aL">
				@Html.TextBoxFor(x => x.GroupName, new { id = "txtGroupName", name = "txtGroupName", @class = "input-style-d" })
				    <span id="spTxtGroupName" style="display:none;"></span>
				</td>
			</tr>
            <tr>
				<td class="aR" style="width:80px;">*备注</td>
				<td class="aL">
				@Html.TextBoxFor(x => x.Memo, new { id = "txtMemo", name = "txtMemo", @class = "input-style-d" })
				    <span id="spTxtMemo" style="display:none;"></span>
				</td>
			</tr>
		</table>
	    <div class="mt10 aC">
		    @Html.HiddenFor(x => x.GroupName, new { id = "hdGroupID" })
            <input type="hidden" name="hdOrgID" value="@ViewData["OrgID"]" />     
            <input id="subbtn" type="button" value="保存" class="i-btn3"/>
            <input type="button" value="取消" onclick="cancel();" class="i-btn3"/>
	    </div>

    </form>
</div>
<script type="text/javascript">
	$("#form1").former({
		submit: 'subbtn',
		style: { right: 'icon-right', error: 'icon-error' },
		ajax: true,
		url: "/AdminGroup/Save",
		//验证规则
		validate: {
			txtGroupName: {
				tipElem: 'spTxtGroupName',
				rules: [
		                { rule: 'EMPTY', txt: '名称不能为空' },
		                { rule: 'LENGTH', min: 0, max: 50, txt: '长度不超过50' }
		            ]
			},
			txtMemo: {
				tipElem: 'spTxtMemo',
				rules: [
		                { rule: 'EMPTY', txt: '备注不能为空' },
		                { rule: 'LENGTH', min: 0, max: 50, txt: '长度不超过50' }
		            ]
			}
		},
		//ajax提交成功执行
		success: function (data) {
			if (data.status === "warning" || data.status === "error") {
				alert(data.msg);
				return false;
			}
			// 操作成功
			alert(data.msg);
			// 执行回调方法
			successHandle();
		},
		//ajax提交失败执行
		error: function (jqXHR, textStatus, errorThrown) {
			alert('发生了未知错误');
		}
	});

	function cancel() {
		window.top.oDG.cancel();
	};

	/**
	* 弹窗处理
	*/
	//窗口回调处理
	function successHandle() {
		window.top.winObj.refresh();
		window.top.oDG.cancel();
	};
</script>